package com.ar.engine;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.graphics.PixelFormat;
import android.hardware.Camera;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;

public class MainActivity extends Activity {
	
	private EngineGLSurfaceView engineSurfaceView;
	
	private Preview mPreview; 
	
	Camera mCamera;
    int numberOfCameras;
    int cameraCurrentlyLocked;

    // The first rear facing camera
    int defaultCameraId;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        EngineRenderer renderer = new EngineRenderer(this);
        
        engineSurfaceView = new EngineGLSurfaceView(this, renderer);
        engineSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16 , 0);
        engineSurfaceView.setRenderer(renderer);
        engineSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
        
        // Forcing full screen window
        setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
        // Adding Camera Feed on OpenGL surface view
        
        mPreview = new Preview(this); 
        
        setContentView(engineSurfaceView);
        addContentView(mPreview, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));  
    }
    
    @Override
    protected void onPause()
    {
    	super.onPause();
    	engineSurfaceView.onPause();
    }
    
    @Override
    protected void onResume()
    {
    	super.onResume();
    	engineSurfaceView.onResume();
    }
}